home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr29 / murexx04.zip / LCALLER.CMD < prev    next >
OS/2 REXX Batch file  |  1994-12-21  |  5KB  |  157 lines

  1. /*                                                                         */
  2. /* Creates a simple last caller list from the LASTUSxx.BBS files written   */
  3. /* by Maximus when a caller is online. Should be called after the caller   */
  4. /* logs off the system. ERRORLEVEL 4 or higher.                            */
  5. /*                                                                         */
  6. /* Don't forget to MECCA(P) it to something Maximus can display. Then all  */
  7. /* you have to do is [link] or [display] it in your WELCOME.MEC or where   */
  8. /* ever you think appropriate.                                             */
  9. /*                                                                         */
  10. '@echo off'
  11.  
  12. Parse Upper Arg UserFile MecFile .
  13. if UserFile = '' Then
  14.     Signal BadArgs
  15.  
  16. If MecFile = '' Then
  17.     Signal BadArgs
  18.  
  19. if Stream(UserFile, 'c', 'query exists')='' Then
  20.     Signal NoUserFile
  21.  
  22. if Stream(MecFile, 'c', 'query exists')<>'' Then Do
  23.     Doscmd = 'DEL 'MecFile
  24.     Doscmd
  25. End
  26.  
  27. Say 'MaxUserREXX Last Caller Utility - Using 'UserFile
  28.  
  29. /* Setup the catch all loader for the user functions                       */
  30. Call RxFuncAdd 'UserLoadFuncs', 'MaxUser', 'UserLoadFuncs'
  31.  
  32. /* Load all the user functions at once                                     */
  33. Call UserLoadFuncs
  34.  
  35. /* Define some constants                                                   */
  36. UserError = 'ERROR'
  37. OutFile = 'LASTCALL.SAV'
  38. HdrFile = 'E:\MAXUSER\LASTCALL.HDR'
  39. Downloads = 0
  40. Uploads = 0
  41. index = 0
  42. MAXENTRIES = 10
  43. MAXNAME = 15
  44. MAXCITY = 20
  45. MAXDATE = 10
  46. MAXCALLS = 7
  47. LINEPAD = 9
  48. col.1 = '[yellow on black]'
  49. col.2 = '[white on black]'
  50. col.3 = '[lightgreen on black]'
  51. col.4 = '[lightcyan on black]'
  52. col.5 = '[lightmagenta on black]'
  53. rColor = Random(1,5)
  54. NC = col.rColor
  55. CC = '[lightred on black]'
  56. DC = '[yellow on black]'
  57. LC = '[white on black]'
  58. EC = '[lightcyan on black]'
  59. LP = Copies(' ', LINEPAD)
  60. HLINE = '[CLS]'x2c('0d')||x2c('0a')
  61. TLINE = EC||LP'┌'Copies('─', MAXNAME+1+MAXCITY+1+MAXDATE+1+MAXCALLS+2)'┐'
  62. MLINE = LP'├'Copies('─', MAXNAME+1+MAXCITY+1+MAXDATE+1+MAXCALLS+2)'┤'
  63. BLINE = LP'└'Copies('─', MAXNAME+1+MAXCITY+1+MAXDATE+1+MAXCALLS+2)'┘'LC
  64.  
  65. /* Open the user file for use */
  66. UserCount = OpenUserFile(UserFile)
  67.  
  68. if UserCount <> UserError then do
  69.  
  70.     /* Gather user information */
  71.     UserName = Left(QueryUserAlias(index), MAXNAME)
  72.     UserCity = Left(QueryUserLocation(index), MAXCITY)
  73.     LastCall = Left(QueryUserLastCallDate(index), MAXDATE)
  74.     NoCalls = Right(QueryUserSystemCalls(index), MAXCALLS)
  75.  
  76.     /* Combine it to form last caller list info line */
  77.     OutStr = LP'│'NC' 'UserName' 'CC||UserCity' 'DC||LastCall' 'LC||NoCalls' 'EC'│'
  78.  
  79.     /* Append info to caller list, and close it */
  80.     Call LineOut OutFile, OutStr
  81.     Call Stream OutFile, 'c', 'close'
  82.  
  83.     /* Trim down the last caller list to MAXENTRIES if necessary */
  84.     idx = 1
  85.     Do While Lines(OutFile)=1
  86.         CallerList.idx = LineIn(OutFile)
  87.         idx = idx + 1
  88.     End
  89.     idx = idx - 1
  90.     Call Stream OutFile, 'c', 'close'
  91.     if idx > MAXENTRIES Then Do
  92.         Doscmd = 'DEL 'OutFile
  93.         Doscmd
  94.         Do i = idx-MAXENTRIES+1 to idx
  95.             Call LineOut OutFile, CallerList.i
  96.         End
  97.         Call Stream OutFile, 'c', 'close'
  98.     End
  99.  
  100.     /* Write out the last caller list header */
  101.     Call LineOut MecFile, HLINE
  102.     if Stream(HdrFile, 'c', 'query exists')<>'' Then Do
  103.         Do Until Lines(HdrFile)=0
  104.             Call LineOut MecFile, LineIn(HdrFile)
  105.         End
  106.     End
  107.  
  108.     /* Write out the caller information */
  109.     Call LineOut MecFile, TLINE
  110.     Call LineOut MecFile, LP'│'NC' 'Left('Caller', MAXNAME)' 'CC||Left('Location', MAXCITY)' 'DC||Left('Date', MAXDATE)' 'LC||Right('Calls', MAXCALLS)' 'EC'│'
  111.     Call LineOut MecFile, MLINE
  112.     Do While Lines(OutFile)=1
  113.         text = LineIn(OutFile)
  114.         Call LineOut MecFile, text
  115.     End
  116.     Call LineOut MecFile, BLINE
  117.     Call LineOut MecFile, ' '
  118.     Call Stream OutFile, 'c', 'close'
  119.  
  120.     /* collect the BBS statistics */
  121.     NodeOneStats = QueryBBS_Stats('D:\Max\BBStat01.BBS')
  122.     NodeTwoStats = QueryBBS_Stats('D:\Max\BBStat02.BBS')
  123.  
  124.     Parse Value NodeOneStats With NOC NOM NODL NOUL NOTC
  125.     Parse Value NodeTwoStats With NTC NTM NTDL NTUL NTTC
  126.  
  127.     NOC = NOC + NTC
  128.     NOM = NOM + NTM
  129.     NODL = NODL + NTDL
  130.     NOUL = NOUL + NTUL
  131.     NOTC = NOTC + 1
  132.  
  133.     /* write the BBS statistics out */
  134.     Call LineOut MecFile, LP||EC'        Total System Calls: 'NC||NOC||EC'    Calls Today: 'CC||NOTC||EC
  135.     Call CharOut MecFile, '      Total Messages Out: 'DC||NOM||EC
  136.     Call LineOut MecFile, '    KBytes DL: 'LC||NODL||EC'    KBytes UL: 'NC||NOUL||EC
  137.  
  138.     Call Stream MecFile, 'c', 'close'
  139.  
  140.     /* Close up shop and free the system resources */
  141.     Call CloseUserFile
  142. end
  143.  
  144. /* We are done, so we can drop all the functions                           */
  145. Call UserDropFuncs
  146. Exit
  147.  
  148. BadArgs:
  149.     Say
  150.     Say 'Usage: LCALLER <LASTUSxx.BBS> <LASTCALL.MEC>'
  151.     Exit 1
  152.  
  153. NoUserFile:
  154.     Say
  155.     Say 'ERROR: UserFile does not exist'
  156.     Exit 2
  157.